package com.wf.day_0531.test4;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author mpk
 * @since 2024/5/31 17:32:00
 */

//4.将字符串中的数值 "9 10 12 6 8 16"使用空格隔开，并且进行降序显示
public class Demo {
    public static void main(String[] args) {


        String str = "9 10 12 6 8 16";

        String[] split = str.split(" ");


        List<String> list = Arrays.asList(split);

        String collect = list.stream()
                .map(Integer::valueOf)
                .sorted(Comparator.reverseOrder())
                .map(Object::toString)
                .collect(Collectors.joining(" ", "[", "]"));

        System.out.println(collect);


    }


}
